# -*- Coding = utf-8 -*-
# @time: 2021/2/1 15:52
# Author: YKL
import MySQLdb

conn = MySQLdb.connect(host='39.105.56.50',port=3306,
                       user='hellokitty',password='Hellokitty.618',
                       database='python2005',charset='utf8')

try:
    # 2.基于连接对象创建游标对象
    with conn.cursor() as cursor:
        index = 0
        for _ in range(100):
            params = []
            for _ in range(1000):
                index += 1
                params.append((f'user{index}','000000'))
            cursor.executemany(
                'insert into tb_test1 (username, password) values (%s,%s)',
                params
            )
    conn.commit()
except MySQLdb.MySQLError as err:
    print(err)
    conn.rollback()
finally:
    conn.close()
